/**
 * 
 */
package Exercise;

import java.util.Arrays;
import java.util.Random;

/**
 * 360笔试
 * 输入
 * 4 5 1 3 2
 * 输出
 * 0 0 2 2 3
 */
public class FromBig360 {

	public static int[] getStatusArray(int[] array) {
		int[] result = new int[array.length];
		result[0] = 0;
		int sum;
		for (int i = 1; i < array.length; i++) {
			sum = 0;
			for (int j = 0; j < i; j++) {
				if (array[j] > array[i]) {
					sum++;
				}
			}
			result[i] = sum;
		}
		return result;
	}

	public static void main(String[] args) {
		Random random = new Random();
		int length = random.nextInt(100);
		int[] arr = new int[length];
		for (int i = 0; i < length; i++) {
			arr[i] = random.nextInt();
		}
		int[] arrar = getStatusArray(arr);
		System.out.println(Arrays.toString(arrar));
	}
}
